﻿@model IEnumerable<RealtyReview.Business.Models.Review.ReviewListViewModel>
@Html.Partial("_PageButtons", new {Id = "manage-reviews"})
<br/>
Все отзывы
<table class="table">
    <tr>
        <th>Id </th>
        <th>Долгота</th>
        <th>Широта</th>
        <th>Цена</th>
        <th>Описание</th>
        <th>Статус</th>
        <th></th>
        <th></th>
    </tr>
    @foreach (var review in Model)
        {
        <tr>
            <td>@review.Id</td>
            <td>@review.Latitude</td>
            <td>@review.Longitude</td>
            <td>@review.Price</td>
            <td>@review.Description</td>
            <td>@review.Status</td>
            <td><button onclick="approveClick('@review.Id');">Approve</button></td>
            <td><button onclick="rejectClick('@review.Id');">Reject</button></td>
        </tr>
        }
</table>

<script type="text/javascript">

    function approveClick(reviewId) {
        $.ajax({
            url: '@Url.Action("Approve", "Manager")',
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            dataType: "json",
            data: JSON.stringify({ reviewId: reviewId }),
            success: function (result) {
                alert(result);
            },
            error: function (error) {
                alert(error);
            }
        });
        return false;
    }

    function rejectClick(id) {
        $.ajax({
            url: '@Url.Action("Reject", "Manager")',
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify({ reviewId: id }),
            dataType: "json",
            processData: true,
            success: function (result) {
                alert(result);
            }
        });
        return false;
    }

</script>